package com.bw.module_home.model.service

import com.bw.lib_net.RetrofitManager
import com.bw.lib_net.entity.ResponseEntity
import com.bw.module_home.model.api.CommentApi
import com.bw.module_home.model.entity.CommentEntity

/**
 * @Author : ZhouZiYao
 * @Time : On 2023/11/29 11:24
 * @Description :
 */
class CommentService {
    val api: CommentApi by lazy {
        RetrofitManager.instance.createService(CommentApi::class.java)
    }

    /**
     * 根据id获取评论信息方法
     * Returns 评论实体对象列表
     */
    suspend fun getCommentById(datatype:Int, itemid:String?): ResponseEntity<MutableList<CommentEntity>> {
        return api.getCommentById(datatype, itemid)
    }

    /**
     * 发布评论
     */
    suspend fun publishComment(entity: CommentEntity) : ResponseEntity<CommentEntity>{
        return api.publishComment(entity)
    }

    /**
     * 删除评论
     */
    suspend fun removeComment(id:Int): ResponseEntity<Boolean>{
        return api.removeComment(id)
    }

    /**
     * 点赞评论
     */
    suspend fun agree(commentid:Int) : ResponseEntity<Boolean>{
        return api.agree(commentid)
    }

    /**
     * 取消点赞
     */
    suspend fun unAgree(commentid:Int) : ResponseEntity<Boolean>{
        return api.unAgree(commentid)
    }

}